package com.ly.consumer.thread.threadCommonMethod;

//线程的join 打断当前主线程 等代子线程执行完毕后在执行主线程
class JoinThread implements Runnable {
    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            System.out.println("子线程");
        }
    }
}
public class MyJoin {
    public static void main(String[] args) throws InterruptedException {
        System.out.println("主线程代码开始");
        JoinThread joinThread = new JoinThread();
        Thread thread = new Thread(joinThread);
        thread.start();
        thread.join();
        System.out.println("主线程代码结束");
    }
}
